using System;
using UnityEngine;

namespace NodeCanvas.DialogueTrees
{
	[Serializable]
	public class Statement
	{
		public string text = string.Empty;

		public AudioClip audio;

		public string meta = string.Empty;

		public Statement()
		{
		}

		public Statement(string text)
		{
			this.text = text;
		}

		public Statement BlackboardReplace(Blackboard bb)
		{
			string text = this.text;
			int startIndex = 0;
			while ((startIndex = text.IndexOf('[', startIndex)) != -1)
			{
				int num = text.Substring(startIndex + 1).IndexOf(']');
				string text2 = text.Substring(startIndex + 1, num);
				string oldValue = text.Substring(startIndex, num + 2);
				object obj = null;
				if (bb != null)
				{
					obj = bb.GetDataValue<object>(text2);
				}
				text = text.Replace(oldValue, (obj == null) ? ("*" + text2 + "*") : obj.ToString());
				startIndex++;
			}
			Statement statement = new Statement(text);
			statement.audio = audio;
			statement.meta = meta;
			return statement;
		}

		public override string ToString()
		{
			return text;
		}
	}
}
